package com.sskj.lib.bean;

import com.sskj.common.base.App;
import com.sskj.lib.R;

import java.io.Serializable;

public enum PayTypeEnum implements Serializable {
    WX("wx",  App.INSTANCE.getString(R.string.lib_payTypeEnum1_j), R.mipmap.lib_icon_wx),
    ALIPAY("alipay",  App.INSTANCE.getString(R.string.lib_payTypeEnum2_j), R.mipmap.lib_icon_alipay),
    BANK("bankcard",  App.INSTANCE.getString(R.string.lib_payTypeEnum3_j), R.mipmap.lib_icon_bank);
    String type;
    String name;
    int res;

    PayTypeEnum(String type, String name, int res) {
        this.type = type;
        this.name = name;
        this.res = res;
    }

    public String getType() {
        return type;
    }

    public String getName() {
        if (this == WX) {
            return App.INSTANCE.getString(R.string.lib_payTypeEnum1_j);
        } else if (this == ALIPAY) {
            return App.INSTANCE.getString(R.string.lib_payTypeEnum2_j);
        } else {
            return App.INSTANCE.getString(R.string.lib_payTypeEnum3_j);
        }
    }

    public int getRes() {
        return res;
    }

    public static PayTypeEnum getByType(String type) {
        if (WX.getType().equals(type)) {
            return WX;
        }
        if (ALIPAY.getType().equals(type)) {
            return ALIPAY;
        }
        if (BANK.getType().equals(type)) {
            return BANK;
        }
        return WX;

    }
}
